package com.pulaien.shop.controller;

import com.pulaien.common.core.controller.BaseController;
import com.pulaien.common.core.domain.AjaxResult;
import com.pulaien.common.utils.SecurityUtils;
import com.pulaien.system.domain.RakutenInfo;
import com.pulaien.system.domain.RakutenOrder;
import com.pulaien.system.service.IRakutenInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 乐天订单信息Controller
 *
 * @author pulaien
 */
@RestController
@RequestMapping("/shop/rakuten/info")
@Api(tags = "乐天商铺信息")
public class ShopRakutenInfoController  extends BaseController {
    @Resource
    private IRakutenInfoService rakutenInfoService;

    /**
     * 同步最新订单
     */
    @ApiOperation(value = "保存店铺信息")
    @PostMapping("/save")
    public AjaxResult save(@RequestBody RakutenInfo rakutenInfo)
    {
        return rakutenInfoService.saveRakutenInfo(rakutenInfo);
    }

    /**
     * 同步最新订单
     */
    @ApiOperation(value = "获取当前用户店铺接口")
    @GetMapping("/getShopInfo")
    public AjaxResult getShop()
    {
        return rakutenInfoService.getByUserId(SecurityUtils.getUserId());
    }

    /**
     * 信息详情
     */
    @ApiOperation(value = "信息详情")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return AjaxResult.success(rakutenInfoService.getInfo(id));
    }

    /**
     * 取消关联店铺
     */
    @ApiOperation(value = "取消关联店铺")
    @GetMapping("/cancelStore")
    public AjaxResult cancelStore(@RequestParam("id")Long id)
    {
        return rakutenInfoService.cancelStore(id);
    }

}
